<!doctype html>

<html>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  <meta charset="utf-8"/>

  <title><%= content_for?(:title) ? yield(:title) : "Lark" %></title>

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

  <%= csrf_meta_tags %>

  <%= stylesheet_link_tag "rediscss/sessionindex.css"%>
  <%= javascript_include_tag "registjs/jquery-1.10.2.min.js" %>
  <%= javascript_include_tag "registjs/jquery.form" %>

</head>
<body>
<div class="main">
  <div class="main_top">
    <div class="logo"><a href="/"><%= image_tag("logo_32.png") %></a></div>
    <div class="main_out">信息登记系统</div>
    <div class="main_txt">欢迎登录</div>
    <%= link_to "登录","/" %>
  </div>
  <div class="con">
    <%= form_tag users_sessions_fix_password_path,class:"bl-form bl-formhor",:id=>"new_user" do |f| %>
        <input type="hidden" name="change_password", value="true" />
        <input type="hidden" name="id", value="<%= @user.id %>" />
          <div class="con_grou">
            <label for="telphone" class="label  one" >信息登记系统帐号：</label>
            <div class="frm_control">
              <input type="text" class="input required" id="telphonen" disabled="disabled" value="<%=  @user.mobile %>">
            </div>   <!--frm_controls-->
          </div>     <!--frm_control_group-->
          <!--手机号-->
          <div class="con_grou">
            <label for="telphone" class="label  one">短信验证码：</label>
            <div class="frm_control">
              <input type="text" class="input"  name="user[tel]" placeholder="请输入手机收到的验证码" required data-msg-required="不能为空">
              <span class="error" style="float: left;margin: 0px"><%= flash[:mes_err] %></span>
            </div>   <!--frm_controls-->
            <div class="clear"></div>
          </div>     <!--frm_control_group-->
          <!--短信验证码-->
          <!--密码-->
          <div class="con_grou">
            <label for="password" class="label one" >设置新的登录密码：</label>
            <div class="frm_control">
              <input class="input" type="password" name="user[password]" value="" placeholder="新密码" required id="password" minlength="6" data-msg-minlength="新密码长度至少6个字符">
            </div> <!--frm_controls-->
          </div>     <!--frm_control_group-->
          <!--密码-->
          <div class="con_grou">
            <label for="confirm_password" class="label one">确认新的登录密码：</label>
            <div class="frm_control">
              <input class="input" type="password"  name="user[password_confirmation]" value="" placeholder="确认新密码" required equalTo="#password">
            </div> <!--frm_controls-->
          </div>     <!--frm_control_group-->
          <!--验证码-->
          <div class="frm_control">
            <input class="submit button01" type="submit" value="确认修改"/>
          </div>    <!--frm_controls-->
    <% end %>
  </div>

  <footer>©www.jiuyunda.net:90</footer>
</div>
</body>
<script>

    $(function(){
        $("#new_user").validate({
            submitHandler: function() {
                form.submit();
            }
        });
        $(".rucaptcha-image-box").click(function(e){
            btn = $(e.currentTarget)
            img = btn.find('img:first')
            currentSrc = img.attr('src');
            img.attr('src', currentSrc.split('?')[0] + '?' + (new Date()).getTime())
            return false
        });
    })

    $.validator.setDefaults({
        errorElement:'span'
    });

    //配置通用的默认提示语
    $.extend($.validator.messages, {
        required: '必填',
        equalTo: "请再次输入相同的值"
    });
    //手机验证规则
    jQuery.validator.addMethod("mobile", function (value, element) {
        var mobile = /^1[3|4|5|7|8]\d{9}$/;
        return this.optional(element) || (mobile.test(value));
    }, "手机格式不对");
    //验证当前值和目标val的值相等 相等返回为 false
    jQuery.validator.addMethod("equalTo2",function(value, element){
        var returnVal = true;
        var id = $(element).attr("data-rule-equalto2");
        var targetVal = $(id).val();
        if(value === targetVal){
            returnVal = false;
        }
        return returnVal;
    },"不能和原始密码相同");

</script>
</html>